# requests的POST
import requests

formdata = {
    "type":"AUTO",
    "i":"i love python",
    "doctype":"json",
    "xmlVersion":"1.8",
    "keyfrom":"fanyi.web",
    "ue":"UTF-8",
    "action":"FY_BY_ENTER",
    "typoResult":"true"
}

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) \
    Chrome/54.0.2840.99 Safari/537.36"}

url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null"

# post方法
response = requests.post(url, data = formdata, headers = headers)

res_body = response.content.decode('utf8')
res_url = response.url
res_encoding = response.encoding
res_statuscode = response.status_code
res_text = response.text
res_json = response.json

print(res_body)
print(res_url)
print(res_encoding)
print(res_statuscode)
print(res_text)
print(res_json)

